package felix.rule.data.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.JsonNode;
import felix.rule.data.msg.EntityRelation;
import felix.rule.data.msg.RelationType;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@TableName("relation")
@Data
@NoArgsConstructor
public class RelationEntity implements ToData<EntityRelation> {
    private String fromId;

    private String toId;

    private RelationType relationType;

    private String type;

    private String entityType;

    private JsonNode additionalInfo;

    public RelationEntity(EntityRelation relation) {
        BeanUtils.copyProperties(relation, this);
    }

    @Override
    public EntityRelation toData() {
        EntityRelation entityRelation = new EntityRelation();
        BeanUtils.copyProperties(this, entityRelation);
        return entityRelation;
    }
}
